import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/19 8:15
 */

public class Solution {
    public int maxTurbulenceSize(int[] arr) {
        // ret用于记录最大湍流子数组长度
        int n = arr.length, ret = 0;
        if (n == 1) {
            return 1;
        }

        int[] f = new int[n];
        int[] g = new int[n];
        // 初始化为1
        for (int i = 0; i < n; i++) {
            f[i] = g[i] = 1;
        }

        for (int i = 1; i < n; i++) {
            if (arr[i] > arr[i - 1]) {
                f[i] = g[i - 1] + 1;
            } else if (arr[i] < arr[i - 1]) {
                g[i] = f[i - 1] + 1;
            }
            ret = Math.max(ret, Math.max(f[i], g[i]));
        }

        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.maxTurbulenceSize(arr));
        }
    }
}